package com.flyway.execise.flyway_db;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @date 19-7-16
 * @auther jackliang
 * @description TODO
 */
@RestController
public class Controller {


    @Autowired
    private Environment environment;

    @Autowired
    private SpringContextUtil springContextUtil;
    @RequestMapping("test")
    public String test()  {
        Path dir = Paths.get(System.getProperty("user.dir") + File.separator + "src");
        new Thread(()-> {
            try {
                new WatcherDIrs(dir, true,environment);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();
        return "hello world~";
    }


    @RequestMapping("test1")
    public String test1() {
        System.out.println("duck112 1dasdaliangwejideuji2424210111111222222");
        return environment.getProperty("helloworld");
    }

}
